home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1997 / MacHack 1997.toast / Hacks / Hacks ’95 / What's On My Mac / cgi.h < prev    next >
C/C++ Source or Header  |  1995-06-24  |  4KB  |  139 lines

  1. #pragma once
  2. /*****
  3.  *
  4.  *    Grant's CGI Shell (Common Grant Interface :-)
  5.  *
  6.  *    cgi.h
  7.  *
  8.  *    standard types and functions for cgi applications
  9.  *
  10.  *    by Grant Neufeld
  11.  *    http://arpp1.carleton.ca/grant/
  12.  *    gneufeld@ccs.carleton.ca
  13.  *    grant@acm.org
  14.  *
  15.  *    Copyright ©1995 by Grant Neufeld
  16.  *
  17.  *    This source may be freely used as long as the copyright notice is kept in the source.
  18.  *    I (we) ask that you let us know of any enhancements (read: bug fixes) to this code.
  19.  *    I (we) would also like copies of (or discounts on) anything you produce this with, please.
  20.  *
  21.  *****/
  22.  
  23.  
  24. /***  CONSTANT DECLARATIONS  ***/
  25.  
  26. #define kCGIParamMaxSize        32767
  27.  
  28. #define kCGIHTTPMethodGet        "GET"
  29. #define kCGIHTTPMethodPost        "POST"
  30.  
  31. #define kCGIFormFieldDelimiter    '='
  32. #define kCGIFormFieldSeparator    '&'
  33.  
  34. #define kCGIpath_args            '----'
  35. #define kCGIhttp_search_args    'kfor'
  36. #define kCGIusername            'user'
  37. #define kCGIpassword            'pass'
  38. #define kCGIfrom_user            'frmu'
  39. #define kCGIclient_address        'addr'
  40. #define kCGIpost_args            'post'
  41. #define kCGImethod                'meth'
  42. #define kCGIserver_name            'svnm'
  43. #define kCGIserver_port            'svpt'
  44. #define kCGIscript_name            'scnm'
  45. #define kCGIcontent_type        'ctyp'
  46. #define kCGIreferer                'refr'
  47. #define kCGIuser_agent            'Agnt'
  48. #define kCGIaction                'Kact'
  49. #define kCGIaction_path            'Kapt'
  50. #define kCGIclient_ip            'Kcip'
  51. #define kCGIfull_request        'Kfrq'
  52.  
  53.  
  54. /***  TYPE DECLARATIONS  ***/
  55.  
  56. typedef struct
  57. {
  58.     char *    name;
  59.     char *    value;
  60. } CGIFormField;
  61.  
  62. typedef enum
  63. {
  64.     HTTP_UNDEFINED,
  65.     HTTP_get,
  66.     HTTP_post
  67. } HTTPMethod;
  68.  
  69. typedef struct
  70. {
  71.     char *        path_args;            /* '----' path_args            */
  72.     char *        http_search_args;    /* 'kfor' http_search_args    */
  73.     char *        username;            /* 'user' username            */
  74.     char *        password;            /* 'pass' password            */
  75.     char *        from_user;            /* 'frmu' from_user            */
  76.     char *        client_address;        /* 'addr' client_address    */
  77.     char *        post_args;            /* 'post' post_args            */
  78.     HTTPMethod    method;                /* 'meth' method            */
  79.     char *        server_name;        /* 'svnm' server_name        */
  80.     short        server_port;        /* 'svpt' server_port        */
  81.     char *        script_name;        /* 'scnm' script_name        */
  82.     char *        content_type;        /* 'ctyp' content_type        */
  83.     char *        referer;            /* 'refr' referer            */
  84.     char *        user_agent;            /* 'Agnt' user_agent        */
  85.     char *        action;                /* 'Kact' action            */
  86.     char *        action_path;        /* 'Kapt' action_path        */
  87.     char *        client_ip;            /* 'Kcip' client_ip            */
  88.     char *        full_request;        /* 'Kfrq' full_request        */
  89.     
  90.     CGIFormField *    formFields;        /* the fields from form submission */
  91.     long            totalFields;    /* total number of fields    */
  92.     
  93.     char *        responseData;        /* the data to be returned    */
  94.     long        responseSize;        /* the size of the response    */
  95.     
  96.     AppleEvent *    appleEvent;        /* originating appleEvent    */
  97.     AppleEvent *    replyEvent;        /* apple event reply record    */
  98. } CGIrecord;
  99.  
  100. typedef CGIrecord ** CGIHdl;
  101.  
  102.  
  103. /***  GLOBAL DECLARATIONS  ***/
  104.  
  105. #ifdef __MainSegment__
  106. #define _GLOBAL_    
  107. #else
  108. #define _GLOBAL_    extern
  109. #endif
  110.  
  111. _GLOBAL_    Str255    gHTTPHeaderOK;
  112. _GLOBAL_    Str255    gHTTPHeaderRedirect;
  113. _GLOBAL_    Str255    gHTTPHeaderErr;
  114. _GLOBAL_    long    gHTTPHeaderOKSize;
  115. _GLOBAL_    long    gHTTPHeaderRedirectSize;
  116. _GLOBAL_    long    gHTTPHeaderErrSize;
  117.  
  118. #undef _GLOBAL_
  119.  
  120.  
  121. /***  FUNCTION PROTOTYPES  ***/
  122.  
  123.         void    InitCGIUtil    ( void );
  124.         
  125.         void    CGIDisposeHandle    ( CGIHdl );
  126.         
  127.         CGIFormField *    CGIFormFieldsFromArgs    ( char *, long * );
  128.         CGIFormField *    CGIFormFieldsFindRecord    ( CGIFormField *, char * );
  129.         void            CGIFormFieldsDispose    ( CGIFormField * );
  130.         
  131.         void            CGIDecodeSpecialChars    ( char * );
  132.         char *            CGIEncodeSpecialChars    ( char * );
  133.         void            CGICharToHex            ( unsigned char, char * );
  134.  
  135. pascal    OSErr    CGIAEHandle    ( AppleEvent *, AppleEvent *, long );
  136.  
  137.  
  138. /***  EOF  ***/
  139.